#pragma once
#include <iostream>
#include <string>
#include <cerrno>
#include <cstring>
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>

using namespace std;

#define FIFO_FILE "./myfifo"
#define MODE 0664 

enum 
{
   FIFO_OPEN_ERR=1,
   FIFO_DELETE_ERR,
   FIFO_CREAT_ERR
};//像类一样设计

class Init
{
public:
  Init()
  {
     int n=mkfifo(FIFO_FILE,MODE);
     if(n==-1)
     {
        perror("open fifo");
        exit(FIFO_CREAT_ERR);
     }
  }

  ~Init()
  {
    int m=unlink(FIFO_FILE);
    if(m==-1)
    {
        perror("delete fifo");
        exit(FIFO_DELETE_ERR);
    }
  }
};